package list;

import java.io.*;

public class Demo14 {
    public static void main(String[] args) {
        /*
         * 从一个文本文件(UTF-8)中统计每个英文大写字符个数
         */
        String file = "笔记/就业冲刺3.md";
        try(
            BufferedReader reader=new BufferedReader(
                new InputStreamReader(
                new BufferedInputStream(
                new FileInputStream(file)),"UTF-8"));
        ) {
            int[] counter = new int[26];
            int ch;
            while ((ch = reader.read()) != -1) {
                System.out.print((char)ch);
                if (ch >= 'A' && ch <= 'Z') {
                    counter[ch - 'A']++;
                }
            }
            char c = 'A';
            for (int n:counter){
                System.out.println((c++) + ":" + n);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
